
import { _decorator, Node, Component, SpriteFrame, Sprite, Label } from "cc";
import ScrollViewItemBase from "./ScrollViewItemBase";


const { ccclass, property } = _decorator;

@ccclass
export default class RankItem extends ScrollViewItemBase {
    @property(SpriteFrame)
    rankImage: Array<SpriteFrame> = []
    @property(Sprite)
    rankIcon: Sprite = null;
    @property(Label)
    rankLabel: Label = null;
    @property(Label)
    nameLabel: Label = null;
    @property(Label)
    numLabel: Label = null;
    public init(index?: number): void {
        super.init(index);
    }
    public updateItem(tmplId: any, data: any): void {
        super.updateItem(tmplId, data)
        this.nameLabel.string = data.username;
        this.numLabel.string = data.diamond;
        if (data.sort < 4) {
            this.rankIcon.node.active = true;
            this.rankLabel.node.active = false;
            this.rankIcon.spriteFrame = this.rankImage[data.sort - 1]
        } else {
            this.rankIcon.node.active = false;
            this.rankLabel.node.active = true;
            this.rankLabel.string = data.sort;
        }
    }
}